package com.fxu.tpl.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fxu.framework.core.base.Cascade;
import com.fxu.framework.core.enums.EnumValid;
import com.fxu.framework.core.enums.StatusEnum;
import com.fxu.framework.core.sql.SEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

import static com.baomidou.mybatisplus.annotation.FieldFill.UPDATE;

/***
 * <p>fxu</p>
 * 测试表：[test_info]实体类
 * @author fxu
 * @version 2021-03-16
 ***/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "TestInfo", description = "级联单表")
@TableName("fxu_test_info")
public class TestInfo extends SEntity<TestInfo> implements Serializable {
/*=== 自动生成代码 开始 ===*/
    private static final long serialVersionUID = 516945524521794738L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "自增ID")
    private Long id;

    @ApiModelProperty(value = "测试表的id")
    private Long testId;

    @ApiModelProperty(value = "信息名字", required = true)
    @NotBlank(message = "信息名字必须赋值")
    @Size(max = 32, message = "信息名字的长度必须小于32位")
    private String name;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "状态[1:正常,0:删除]")
    @EnumValid(target = StatusEnum.class, message = "状态的值必须为{1:正常,0:删除}")
    private Integer status;

    @TableField(fill = UPDATE, update = "%s+1")
    @ApiModelProperty(value = "版本号")
    private Integer version;

    @TableField(exist = false)
    @ApiModelProperty(value = "测试表的id对象")
    @Cascade(thisField = "testId", linkField = "id")
    private Test test;

    // 获得状态的说明
    public String getStatusText() {
        return StatusEnum.desc(status);
    }
/*=== 自动生成代码 结束 ===*/
}
